package com.atguigu.tingshu.user.rpc;

import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.user.VipServiceConfig;
import com.atguigu.tingshu.user.service.UserInfoService;
import com.atguigu.tingshu.vo.account.AccountLockResultVo;
import com.atguigu.tingshu.vo.account.AccountLockVo;
import com.atguigu.tingshu.vo.user.UserInfoVo;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/api/rpc/userinfo")
public class UserInfoRpcController {
    @Autowired
    private UserInfoService userInfoService;
    @GetMapping(value = "/getUserInfo/{userId}")
    @Operation(summary = "查询用户微服务获取用户的基本信息")
    Result<UserInfoVo> getUserInfo(@PathVariable(value = "userId") Long userId) {
        UserInfoVo userInfoVo = userInfoService.getUserInfo(userId);
        return Result.ok(userInfoVo);
    }
    @GetMapping(value = "/getUserPaidAlbumTrackList/{albumId}/{userId}")
    @Operation(summary = "查询用户微服务获取用户已购买专辑声音列表")
    Result<Map<Long, String>> getUserPaidAlbumTrackList(@PathVariable(value = "albumId") Long albumId, @PathVariable(value = "userId") Long userId){
        Map<Long, String> map = userInfoService.getUserPaidAlbumTrackList(albumId, userId);
        return Result.ok(map);
    }
    @GetMapping(value = "/getUserPaidAlbum/{albumId}/{userId}")
    @Operation(summary = "查询用户微服务获取用户是否购买了专辑")
    Result<Boolean> getUserPaidAlbum(@PathVariable(value = "albumId") Long albumId, @PathVariable(value = "userId") Long userId){
        Boolean isPaidAlbum = userInfoService.getUserPaidAlbum(userId,albumId);
        return Result.ok(isPaidAlbum);
    }
    @GetMapping("/getAllVipConfig/{itemId}")
    @Operation(summary = "查询用户微服务获取对应服务配置")
    Result<VipServiceConfig> getAllVipConfig(@PathVariable(value = "itemId") Long itemId){
        VipServiceConfig vipServiceConfig = userInfoService.getAllVipConfig(itemId);
        return Result.ok(vipServiceConfig);
    }

}
